package com.springboot.ykz.dependinject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component("B_person")
public class BusinessPerson implements Person {
    @Qualifier("dog")
    @Autowired
    private Animal animal=null;
    public BusinessPerson(@Qualifier("cat") Animal animal) {
        System.out.println("人类的构造方法");
        this.animal=animal;
    }

    public void service() {
        System.out.println("person use:");
        this.animal.use();
    }

    public void setAnimal(Animal animal) {
        this.animal=animal;
    }
}
